import queue

class QueueItem:
    def __init__(self, type, data) -> None:
        self.type = type
        self.data = data

class ComfyQueue:
    _instance = None

    def __new__(cls, *args, **kwargs):
        """
        队列单例模式
        """
        if cls._instance is None:
            cls._instance = super(ComfyQueue, cls).__new__(cls, *args, **kwargs)
        return cls._instance
    
    def __init__(self):
        self.queue = queue.Queue()

    def run(self):
        print('run queue task')

    def put(self, item: QueueItem):
        self.queue.put(item)

    def delete(self, item=QueueItem):
        self.queue.put(item)
